from collections import Counter
import re

with open("input.txt") as file:
    count = 0 

    for line in file.readlines():
        low, high, c, word = re.findall(r"(\d+)-(\d+) (\w): (\w+)", line.strip())[0]
        low, high = int(low), int(high)

        if (word[low - 1] == c) ^ (word[high - 1] == c):
            count += 1

    print(count)
